Skip to content

Resolve ambiguous column names in ORDER BY#231

Closed
adamziel wants to merge 3 commits intodevelopfrom
ambiguous-column-name-in-order-by
Closed

Resolve ambiguous column names in ORDER BY#231
adamziel wants to merge 3 commits intodevelopfrom
ambiguous-column-name-in-order-by

Conversation

@adamziel
Copy link
Collaborator

@adamziel adamziel commented Aug 26, 2025

🚧 WIP 🚧

GPT 5-assisted solution for #230. The logic seems in tact, this PR needs reformatting and a pass over the comments to better explain the context

Follow-up work

Explore whether this solution needs to also be applied to column names in LIMIT, HAVING, GROUP BY, etc.

@adamziel adamziel requested a review from JanJakes August 26, 2025 19:19
@adamziel
Copy link
Collaborator Author

@JanJakes It seems like it works but something's off in the CI setup with the TLS certificate errors. I won't be able to address that today – would you be able to take over?

* @see https://github.com/wordpress/sqlite-database-integration/issues/228
* @var array<int, array<string, string|null>> Stack of frames: name(lowercase) → expression|null
*/
private $select_output_name_to_ordinal_stack = array();
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this name. Maybe $selected_columns_stack?

@JanJakes
Copy link
Member

JanJakes commented Sep 1, 2025

Oh wow, what a complexity (maintaining the stack, etc.) and dirty code. Nope, GPT-5, not good.

I had something much simpler in mind with a top-down approach. Gave it a quick shot in #232. The first commit is all that is needed, the second one covers an advanced edge case. I think it's almost good to go and likely much more correct. I will double-check and finalize it tomorrow.

@adamziel adamziel closed this Sep 2, 2025
adamziel added a commit that referenced this pull request Sep 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants